package io;

import java.io.BufferedWriter;
import java.io.ByteArrayOutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.nio.charset.StandardCharsets;
import java.sql.Array;
import java.util.Arrays;

public class BAOSDemo {
    public static void main(String[] args) {

        //ByteArrayOutStream低级流不要求强行捕获异常，也不要求关闭。

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        OutputStreamWriter osw = new OutputStreamWriter(baos, StandardCharsets.UTF_8);
        BufferedWriter bw = new BufferedWriter(osw);
        PrintWriter pw = new PrintWriter(bw,true);

        pw.println("你好");
        byte[] data = baos.toByteArray();//获取字节数组的内容

        System.out.println(data.length);
        System.out.println(Arrays.toString(data));

    }
}
